def merge_sort(list):
    if len(list) <= 1:
        return list, 0
    mid = len(list) // 2
    l, lc = merge_sort(list[:mid])
    r, rc = merge_sort(list[mid:])
    c = lc + rc

    i, j = 0, 0
    ans = []
    while i < len(l) and j < len(r):
        if l[i] > r[j]:
            ans.append(l[i])
            c += len(r)-j
            i += 1
        else:
            ans.append(r[j])
            j += 1
    ans += l[i:]
    ans += r[j:]
    return ans, c

long = int(input())
string1 = input().split(" ")
nums = [int(string1[i]) for i in range(long)]
sn = [0 for i in range(long)]
nums, ans = merge_sort(nums)
print(ans)
